import express from 'express';

const app = express();
const port = 3000;

// 解析JSON请求体
app.use(express.json());

// 根路径的GET请求处理
app.get('/', (req, res) => {
    res.send('Hello, World! This is a TypeScript HTTP server.');
});

// 示例API接口
app.get('/api/users', (req, res) => {
    const users = [
        { id: 1, name: 'Alice' },
        { id: 2, name: 'Bob' },
        { id: 3, name: 'Charlie' }
    ];
    res.json(users);
});

// 启动服务器
app.listen(port, () => {
    console.log(`Server running on port ${port}`);
});
    